cmake_minimum_required(VERSION 3.10.3)
project(NetFox4Nix)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

if (APPLE)
    set(NFSystemDir "osx")
    #OSX上强制生成so后缀的动态库而不是dylib后缀动态库
    set(CMAKE_SHARED_LIBRARY_SUFFIX ".so")
elseif (UNIX)
    set(NFSystemDir "linux")
else ()
    set(NFSystemDir "windows")
endif ()

if (UNIX)
    if (CMAKE_BUILD_TYPE STREQUAL "Debug")
        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -std=c++20 -pthread -O0 -Wall -g -ggdb -DDEBUG")
    else ()
        set(CMAKE_BUILD_TYPE "Release")
        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -std=c++20 -pthread -O3 -Wall")
    endif ()

    set(LDFLAGS "$ENV{LDFLAGS} -stdlib=libc++")
else ()
    set(CMAKE_CXX_FLAGS "-D_X64 -D_WINDOWS -DNOMINMAX /EHsc")
    add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8 /await>")
    add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8 /await>")
endif ()

set(NFOutputDir "${PROJECT_SOURCE_DIR}/_Out/${CMAKE_BUILD_TYPE}")
set(NFIncludeDir "${CMAKE_SOURCE_DIR}" "${CMAKE_SOURCE_DIR}/Dependencies/include/${NFSystemDir}")
set(NFLibraryDir "${NFOutputDir}" "${CMAKE_SOURCE_DIR}/Dependencies/lib/${NFSystemDir}/${CMAKE_BUILD_TYPE}")

message(STATUS "NFOutputDir:${NFOutputDir}")
message(STATUS "NFIncludeDir:${NFIncludeDir}")
message(STATUS "NFLibraryDir:${NFLibraryDir}")

add_compile_definitions(FMT_HEADER_ONLY=1)

# 以下两个尚未找到合适的替换
include_directories(${NFIncludeDir})
link_directories(${NFLibraryDir})

add_subdirectory(Benchmark)
add_subdirectory(Correspond)
add_subdirectory(KernelEngine)
add_subdirectory(LogonServer)
add_subdirectory(ServiceCore)
add_subdirectory(Translator)
